with Ada.Calendar;
with Ada.Strings.Unbounded;

with Win32.Windef;

with win32api_interface.process;        use win32api_interface.process;
with win32api_interface.process.helper;

package win32api_interface.Enum_Windows is
  type result_info is record
    wTitle : Ada.Strings.Unbounded.Unbounded_String;
    hProc  : Process_ID;
  end record;
  type result_info_array is array (Positive range <>) of result_info;

  ---------------
  --  EnumProc --
  ---------------

  function EnumWindowsProc (hwnd   : Win32.Windef.HWND;
                            lParam : Win32.LPARAM) return Win32.Bool;
  pragma convention (STDCALL, EnumWindowsProc);

  function Enumerate_Windows(Class, pName : in string) return result_info_array;
  --  Enumerates Top Level windows.
private
  protected callback_time is
    procedure update;
    function retrieve return Ada.Calendar.Time;
  private
    t : Ada.Calendar.Time;
  end callback_time;

  type block;
  type p_block is access block;
  type block is record
    inf : result_info;
    p : p_block;
  end record;

  list : P_block := null;
  list_n : integer := 0;

  subtype title_range is Positive range 1..Win32.Windef.MAX_PATH;
  type param_type is record
    Class : Win32.Char_Array(title_range);
    pName : Win32.Char_Array(title_range);
  end record;
  type p_param_type is access param_type;
  p_param : p_param_type;

  procedure add(inf : in result_info);
  function to_array_and_clear return result_info_array;
  procedure clear;
end win32api_interface.Enum_Windows;
